package com.oms.common.utils.date;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/***
 * 当天时间工具类
 * @author lucas
 */
public class DayTimeUtil {
    /***
     * 根据传入的日期，返回当天的开始时间和结束时间
     * @param day
     * @return
     */
    public static List<Date> dayStartEndTime(Date day){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(day);
        calendar.set(Calendar.HOUR, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        Date startDay = calendar.getTime();
        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(day);
        calendar1.set(Calendar.HOUR, 23);
        calendar1.set(Calendar.MINUTE, 59);
        calendar1.set(Calendar.SECOND, 59);
        Date endDay = calendar1.getTime();
        List<Date> list = new ArrayList<>();
        list.add(startDay);
        list.add(endDay);
        return list;
    }
}
